home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12752 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: news.compuserve.com!newsmaster
  2. From: 71247.3221@compuserve.com (Don Wallace)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Communication between WIN apps?
  5. Date: Thu, 21 Mar 1996 17:34:04 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4irph0$q1e@dub-news-svc-1.compuserve.com>
  8. References: <4im3n4$hor@lantana.singnet.com.sg>
  9. NNTP-Posting-Host: hd27-073.compuserve.com
  10. X-Newsreader: Forte Free Agent v0.55
  11.  
  12. mikhail@singnet.com.sg (Mikhail Choo W.M.) wrote:
  13.  
  14. >Hi there,
  15. >     I was wondering if there is a way for windows applications to communicate
  16. >between one another. I have looked high and low, and couldn't find any functions
  17. >that would do the tasks. Alas, I found an example of a program that is able to
  18. >communicate, BUT the program is sooooo dammed long and I am just wondering if
  19. >any of you have any better ideas. Oh yes, the app I found comes with borland C++
  20. >4.5 and is called <tstapp>. So, any ideas on how to pass variables to and fro.
  21. >Any help or ideas will be greatly appreciated.
  22. >--------------------------------------------------------
  23. >Yours, Mikhail Choo W. M.            
  24. >                                   Carpedium!
  25. >E-Mail: mikhail@singnet.com.sg        sieze the day...  >        s7700017@singnet.com.sg
  26. >-------------------------------------------------------- 
  27.  
  28. You could define your own Windows messages. The constant WM_USER is
  29. the base of a range of mesage 'slots' available for application
  30. defined purposes. You could define a private, low-overhead message
  31. 'channel' between apps.
  32.  
  33. You then need a window owned by each app which provides the
  34. source/destination of the messages. This window should be hidden in
  35. each app and reserved for messaging. Messages sent to an app for
  36. communication purposes would be directed to this window. Each side
  37. could use 'FindWindow()' to locate the HWND handle.
  38.  
  39. Lastly, you need to define a protocol. If you have a complex thing to
  40. send, I'd use a memory struct to pass the message information.  
  41. An example protocol would be to use 'SendMessage' to send the message
  42. WM_USER+1000; the 'lParam' would be a far pointer at the memory
  43. structure; both sides would have to agree on the format of the struct.
  44.  
  45. This scheme is very simple to implement and has the advantage of not
  46. using any external DLLs or APIs except SendMessage. But it's not good
  47. for end user programmability.
  48.  
  49. On the other hand, you could use DDE, but its API may be a bit more
  50. cumbersome. 
  51.  
  52. - Don
  53.  
  54.